#include <GL/glew.h>
#include <GL/glut.h>


#include <iostream>
#include <string>
#include <cstring>
#include "config.h"
#include "matrix.h"

#include "ui/shader.h"
#include "ui/glframe.h"
#include "gpgpu.h"
#include "waveframe.h"

int main()
{
	try 
	{
		math::ui::GLApp <WaveFrame> app; 
		app.init ();
		app.run(); 
	}
	catch (const char * errmsg)
	{
		std::cerr << errmsg <<std::endl;
	}
	return 0; 
}
/*
int main (int argc, char * argv[])
{
	glutInit (&argc, argv);
    glutCreateWindow("TEST1");	
	glewInit();

	FBO fbo ;
	fbo.create(3);
	fbo.bind(); 

	Shader shader ;
	shader.load ("../glsl/test.vert", "../glsl/test.frag");


	unsigned row = 4; 
	unsigned col = 2;

	TextureMemory2D data   (row, col);
	typedef Texture::frgba_type frgba_type ;
	for (unsigned i = 0;  i < row; ++i)
		for (unsigned j = 0 ; j < col; ++j)
			data.write (i,j , frgba_type(i,j, i, j)); 

	Texture tex1(row, col) ;  // x = 4 , y = 2; 
	Texture tex2(row, col) ;


	tex1.init ();  
	tex2.init(); 
	tex1.bind(); 
	tex1.write_gpu (data); 
	tex1.write_gpu (0, 1, frgba_type(5, 5, 0, 5));


    // One pass
	//tex1.set_viewport();
	//tex1.attach (fbo.get_buffer (0)) ;
	//tex1.draw_buffer(); 
	//glActiveTexture(GL_TEXTURE0);
	//tex1.run(shader); 

	// Alternate passes
	tex1.set_viewport(); 
	tex1.attach (fbo.get_buffer (0)) ;
	tex2.attach (fbo.get_buffer (1)) ;

	tex2.draw_buffer (); 
	glActiveTexture(GL_TEXTURE0);
	tex1.bind(); 
	tex1.run(shader);

	tex1.draw_buffer () ;
	glActiveTexture(GL_TEXTURE0);
	tex2.bind(); 
	tex2.run(shader);

	std::cout<<"Tex 1"<<std::endl;
	tex1.print();
	std::cout<<"Tex 2"<<std::endl;
	tex2.print();

	return 0;
}
*/
